package com.gorkr;

/**
 * 条约游戏Ⅱ
 * @author gorkr
 * @date 2021/12/28 20:51
 **/
public class L45 {
    public int jump(int[] nums) {
        int n = nums.length;
        int res = 0;
        int end = 0, farthest = 0;

        for (int i = 0; i < n-1; i++) {
            farthest = Math.max(farthest, nums[i]+i);
            if(end == i){
                res++;
                end = farthest;
            }

        }
        return res;
    }

}
    